// var i;
// var AL_GAME_HUA_Instance = require("./AL_GAME_HUA_Instance");
// var AL_GAME_HUA_Define = require("./AL_GAME_HUA_Define");
// var AL_GAME_HUA_PopupSelf = require("./AL_GAME_HUA_PopupSelf");
// var AL_GAME_HUA_AwardConfig = require("./AL_GAME_HUA_AwardConfig");
// var AL_GAME_HUA_GameData = require("./AL_GAME_HUA_GameData");
// var f = cc._decorator;
// var d = f.ccclass;
// var h = f.property;
// var _ =
//     (f.menu,
//     (function (e) {
//         function t() {
//             var t = (null !== e && e.apply(this, arguments)) || this;
//             t.label_star_count = null;
//             t.label_progress = null;
//             t.progress_bar = null;
//             return t;
//         }
//         __extends(t, e);
//         t.prototype.zhixing_chushihua_chuli = function () {
//             var e = AL_GAME_HUA_GameData.GameData.getInstance();
//             var t = AL_GAME_HUA_AwardConfig.AwardConfig.getInstance();
//             if (AL_GAME_HUA_Instance.Instance.LevelType == AL_GAME_HUA_Define.Define.LevelType.NORMAL) {
//                 var n = e.huoqu_jiangli_shuliang();
//                 var o = t.genju_jishu_huoqu_jianli_xinxi(n).level;
//                 this.label_progress.string = e.huoqu_dangqian_guanqia() - 1 + "/" + o;
//                 this.progress_bar.progress = (e.huoqu_dangqian_guanqia() - 1) / o;
//             } else {
//                 if (AL_GAME_HUA_Instance.Instance.LevelType == AL_GAME_HUA_Define.Define.LevelType.SPECIAL) {
//                     n = e.huoqu_teshu_jiangli_shuliang();
//                     o = t.genju_jishu_huoqu_jianli_xinxi(n).level;
//                     this.label_progress.string = e.huoqu_dangqian_teshu_guanqia() - 1 + "/" + o;
//                     this.progress_bar.progress = (e.huoqu_dangqian_teshu_guanqia() - 1) / o;
//                 }
//             }
//         };
//         t.prototype.start = function () {
//             AL_GAME_HUA_Instance.Instance.xianshi_dingbu_tiao({
//                 target: this.node,
//                 showAll: !0
//             });
//         };
//         t.prototype.handle_button_callback = function (e, t) {
//             switch (t) {
//                 case "back":
//                     AL_GAME_HUA_Instance.Instance.jinru_zhujiemian();
//                     break;
//                 case "continue":
//                     AL_GAME_HUA_Instance.Instance.jiancha_tili_shifou_zugou(function () {
//                         AL_GAME_HUA_Instance.Instance.qianwang_youxi();
//                     });
//             }
//         };
//         __decorate([h(cc.Label)], t.prototype, "label_star_count", void 0);
//         __decorate([h(cc.Label)], t.prototype, "label_progress", void 0);
//         __decorate([h(cc.ProgressBar)], t.prototype, "progress_bar", void 0);
//         return __decorate([d], t);
//     })(AL_GAME_HUA_PopupSelf.default));
// exports.default = _;


// 引入所需的模块
const AL_GAME_HUA_Instance = require("./AL_GAME_HUA_Instance");
const AL_GAME_HUA_Define = require("./AL_GAME_HUA_Define");
const AL_GAME_HUA_PopupSelf = require("./AL_GAME_HUA_PopupSelf");
const AL_GAME_HUA_AwardConfig = require("./AL_GAME_HUA_AwardConfig");
const AL_GAME_HUA_GameData = require("./AL_GAME_HUA_GameData");

// Cocos Creator 装饰器
const { ccclass, property, menu } = cc._decorator;

/**
 * 游戏过程控制类
 */
@ccclass
class LevelProgress extends AL_GAME_HUA_PopupSelf.default {
    // 星星数量显示节点
    @property(cc.Label)
    label_star_count = null;

    // 进度标签节点
    @property(cc.Label)
    label_progress = null;

    // 进度条节点
    @property(cc.ProgressBar)
    progress_bar = null;

    /**
     * 初始化方法，根据不同关卡类型显示当前进度
     */
    zhixing_chushihua_chuli() {
        const gameDataInstance = AL_GAME_HUA_GameData.GameData.getInstance();
        const awardConfigInstance = AL_GAME_HUA_AwardConfig.AwardConfig.getInstance();
        
        if (AL_GAME_HUA_Instance.Instance.LevelType === AL_GAME_HUA_Define.Define.LevelType.NORMAL) {
            const currentAwardNum = gameDataInstance.huoqu_jiangli_shuliang();
            const levelData = awardConfigInstance.genju_jishu_huoqu_jianli_xinxi(currentAwardNum).level;
            this.label_progress.string = `${gameDataInstance.huoqu_dangqian_guanqia() - 1}/${levelData}`;
            this.progress_bar.progress = (gameDataInstance.huoqu_dangqian_guanqia() - 1) / levelData;
        } else if (AL_GAME_HUA_Instance.Instance.LevelType === AL_GAME_HUA_Define.Define.LevelType.SPECIAL) {
            const specialAwardNum = gameDataInstance.huoqu_teshu_jiangli_shuliang();
            const levelData = awardConfigInstance.genju_jishu_huoqu_jianli_xinxi(specialAwardNum).level;
            this.label_progress.string = `${gameDataInstance.huoqu_dangqian_teshu_guanqia() - 1}/${levelData}`;
            this.progress_bar.progress = (gameDataInstance.huoqu_dangqian_teshu_guanqia() - 1) / levelData;
        }
    }

    /**
     * 启动方法，显示顶部栏
     */
    start() {
        AL_GAME_HUA_Instance.Instance.xianshi_dingbu_tiao({
            target: this.node,
            showAll: true
        });
    }

    /**
     * 按钮回调处理
     * @param {Event} event - 事件对象
     * @param {string} action - 回调动作
     */
    handle_button_callback(event, action) {
        switch (action) {
            case "back":
                AL_GAME_HUA_Instance.Instance.jinru_zhujiemian();
                break;
            case "continue":
                AL_GAME_HUA_Instance.Instance.jiancha_tili_shifou_zugou(() => {
                    AL_GAME_HUA_Instance.Instance.qianwang_youxi();
                });
                break;
        }
    }
}

exports.default = LevelProgress;